var price = new Vue({
	el: '#price',
	data: {
		page_size: 20,
		page_num: 1,
		page_num2: 1,
		total: 0,
		total2: 0,
		shucaiList: [],
		caoyaoList: [],
		type: 0,
		sort_metho: 'desc',
		sort_field: 'release_date',
		sort_metho2: 'desc',
		nameparam: ''
	},
	watch: {

	},
	mounted: function() {
		this.getShuCaiPrice()
		this.getCaoYaoPrice()
	},
	filters: {
		timeformat: function(value) {

			return value.slice(0, 10)
		}

	},
	methods: {
		changeType: function(num) {
			console.log(num)
			this.type = num
		},
		research: function() {

			this.shucaiList = []
			this.caoyaoList = []
			this.page_num = 1
			this.page_num2 = 1
			this.getShuCaiPrice()
			this.getCaoYaoPrice()

		},
		changeSort: function() {
			this.shucaiList = []
			this.caoyaoList = []
			this.page_num = 1
			this.page_num2 = 1
			if(this.type == 0 && this.sort_metho == 'desc') {
				this.sort_metho = 'asc'
				console.log(1)
			} else if(this.type == 0 && this.sort_metho == 'asc') {
				this.sort_metho = 'desc'
				console.log(2)
			}
			if(this.type == 1 && this.sort_metho2 == 'desc') {
				this.sort_field = 'spell'
				this.sort_metho2 = 'asc'
				console.log(3)
			} else if(this.type == 1 && this.sort_metho2 == 'asc') {
				this.sort_field = 'spell'
				this.sort_metho2 = 'desc'
				console.log(4)
			}

			this.getShuCaiPrice();
			this.getCaoYaoPrice();
		},
		getShuCaiPrice: function() {

			var _this = this
			var timestamp = new Date().getTime();
			var param = _this.page_size + '' + _this.page_num + _this.sort_metho + 'spell' + _this.nameparam;

			axios({
				url: datashang + '/farm/priceYnList?sid=pro_data_acq&timestamp=' + timestamp + '&token=' + encrty(param, datashangkey, timestamp) + '&page_size=' + _this.page_size + '&page_num=' + _this.page_num + '&sort_method=' + _this.sort_metho + '&sort_field=spell' + '&name=' + _this.nameparam,
				method: 'POST',
				params: {},
				timeout: 50000,
				// 设置请求头
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
			}).then(function(res) {
				if(res.data.success == 1) {
					var list = res.data.data.data
					var temp = _this.shucaiList
					_this.shucaiList = []
					_this.shucaiList = temp.concat(res.data.data.data)
					_this.total = list.length
					_this.page_num = _this.page_num + 1
					$('.bottom-line').css('display', 'none');
				}
			})
		},
		getCaoYaoPrice: function() {
			var _this = this
			var timestamp = new Date().getTime();

			var param = _this.page_size + '' + _this.page_num2 + _this.sort_metho2 + _this.sort_field + _this.nameparam;

			axios({
				url: datashang + '/plant/priceList?sid=pro_data_acq&timestamp=' + timestamp + '&token=' + encrty(param, datashangkey, timestamp) + '&page_size=' + _this.page_size + '&page_num=' + _this.page_num + '&sort_method=' + _this.sort_metho2 + '&sort_field=' + _this.sort_field + '&name=' + _this.nameparam,
				method: 'POST',
				params: {},
				timeout: 50000,
				// 设置请求头
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
			}).then(function(res) {
				debugger
				if(res.data.success == 1) {

					var list = res.data.data.data
					var temp = _this.caoyaoList
					_this.caoyaoList = []
					_this.caoyaoList = temp.concat(res.data.data.data)
					_this.total2 = list.length
					_this.page_num2 = _this.page_num2 + 1
					$('.bottom-line2').css('display', 'none');
				}
			})
		}
	},
});